package com.zq.designpaterns.structure.adapter;

/**
 * ================================================
 * 作    者：程志强
 * 邮    箱：cheng.zhiqiang@cesgroup.com.cn
 * 版    本：1.0.0
 * 创建日期：2021/01/11  17:56
 * 修改日期：
 * 描    述：
 * 修订历史：
 * ================================================
 */
public class MediaAdapter implements MediaPlayer {

    private AdvancedMediaPlayer mediaPlayer;

    public MediaAdapter(String mediaType) {
        if ("vlc".equals(mediaType)) {
            mediaPlayer = new VlcPlayer();
        } else if ("mp4".equals(mediaType)) {
            mediaPlayer = new Mp4Player();
        }
    }

    @Override
    public void play(String audioType, String fileName) {
        if ("vlc".equals(audioType)) {
            mediaPlayer.playVlc(fileName);
        } else if ("mp4".equals(audioType)) {
            mediaPlayer.playMp4(fileName);
        }
    }
}
